#ifndef FFMPEGEXTRA_EYERWASMHTTP_HPP
#define FFMPEGEXTRA_EYERWASMHTTP_HPP

#include <string>
#include <stdint.h>

#include "EyerWASMEventXMLHttpRequest.hpp"
#include "EyerWASMHttpFetch_FetchEvent.hpp"

namespace Eyer
{
    class EyerWASMHttp
    {
    public:
        EyerWASMHttp(const std::string & _url, int64_t _rangeStart = -1, int64_t _rangeEnd = -1);
        ~EyerWASMHttp();

        int Send();

        int WaitHttpHeader();
        int WaitHttpBody();
        int Abort();

        int GetHttpStatus();
        int GetBufferLen();
        uint8_t * GetBuffer();

        int64_t GetContentLength();
        int64_t GetRangeLength();

    private:
        std::string url;
        int64_t rangeStart = -1;
        int64_t rangeEnd = -1;
        std::shared_ptr<EyerWASMHttpFetch_FetchEvent> event = nullptr;
    };
}

#endif //FFMPEGEXTRA_EYERWASMHTTP_HPP
